﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zen4SyncPOCO.Enum.MergeSync;
using System.Data.SqlServerCe;
using System.Data;
using Zen4SyncPOCO.Enum.Admin;

namespace Zen4SyncClient
{
    /// <summary>
    /// Provides methods to get the .NET equivalent enum of Zen4Sync enums.
    /// </summary>
    internal static class EnumConverter
    {
        internal static NetworkType ConvertNetworkType( NetworkTypeEnum z4sNetworkType )
        {
            switch ( z4sNetworkType )
            {
                case NetworkTypeEnum.DefaultNetwork:
                    return NetworkType.DefaultNetwork;
                case NetworkTypeEnum.MultiProtocol:
                    return NetworkType.MultiProtocol;
                case NetworkTypeEnum.TcpIpSockets:
                    return NetworkType.TcpIpSockets;
                default:
                    throw new Exception( String.Format( "Unknown Zen4Sync Network Type : {0}", z4sNetworkType.ToString() ) );
            }
        }

        internal static SecurityType ConvertSecurityType( SecurityTypeEnum z4sSecurityType )
        {
            switch ( z4sSecurityType )
            {
                case SecurityTypeEnum.DBAuthentication:
                    return SecurityType.DBAuthentication;
                case SecurityTypeEnum.NTAuthentication:
                    return SecurityType.NTAuthentication;
                default:
                    throw new Exception( String.Format( "Unknown Zen4Sync Security Type : {0}", z4sSecurityType.ToString() ) );
            }
        }

        internal static ExchangeType ConvertExchangeType( ExchangeTypeEnum z4sExchangeType )
        {
            switch ( z4sExchangeType )
            {
                case ExchangeTypeEnum.BiDirectional:
                    return ExchangeType.BiDirectional;
                case ExchangeTypeEnum.None:
                    return ExchangeType.None;
                case ExchangeTypeEnum.Upload:
                    return ExchangeType.Upload;
                default:
                    throw new Exception( String.Format( "Unknown Zen4Sync Exchange Type : {0}", z4sExchangeType.ToString() ) );
            }
        }

        internal static SnapshotTransferType ConvertSnapshotTransferType( SnapshotTransfertTypeEnum z4sSnapshotTransfertType )
        {
            switch ( z4sSnapshotTransfertType )
            {
                case SnapshotTransfertTypeEnum.FTP:
                    return SnapshotTransferType.FTP;
                case SnapshotTransfertTypeEnum.UNC:
                    return SnapshotTransferType.UNC;
                default:
                    throw new Exception( String.Format( "Unknown Zen4Sync Snapshot Transfer Type : {0}", z4sSnapshotTransfertType.ToString() ) );
            }
        }

        internal static SqlDbType ConvertSqlType( SqlValueTypeEnum z4sSqlType )
        {
            switch ( z4sSqlType )
            {
                case SqlValueTypeEnum.UniqueIdentifier:
                    return SqlDbType.UniqueIdentifier;
                case SqlValueTypeEnum.Int:
                    return SqlDbType.Int;
                case SqlValueTypeEnum.Nvarchar:
                    return SqlDbType.NVarChar;
                case SqlValueTypeEnum.Bit:
                    return SqlDbType.Bit;
                case SqlValueTypeEnum.DateTime:
                    return SqlDbType.DateTime;
                case SqlValueTypeEnum.Xml:
                    return SqlDbType.Xml;
                case SqlValueTypeEnum.SmallInt:
                    return SqlDbType.SmallInt;
                default:
                    throw new Exception( String.Format( "Unknown Zen4Sync SQL Type : {0}", z4sSqlType.ToString() ) );
            }
        }

        internal static ValidateType ConvertValidateType(ValidateTypeEnum z4sValidateType)
        {
            switch (z4sValidateType)
            {
                case ValidateTypeEnum.NoValidation:
                    return ValidateType.NoValidation;
                case ValidateTypeEnum.RowCountOnly:
                    return ValidateType.RowCountOnly;
                default:
                    throw new Exception(String.Format("Unknown Zen4Sync ValidateType : {0}", z4sValidateType.ToString()));
            }
        }
    }
}
